<template>
  <div id="app">
    <title_bar />
    <div class="router-view" v-if="flag">
      <router-view />
    </div>
  </div>
</template>

<style lang="less" scoped>
#app {
  width: 100%;
  height: 100%;
  .router-view {
    width: 100%;
    height: calc(100vh - var(--title-height));
  }
}
</style>

<script setup>
import { onBeforeMount, ref } from "vue";
import title_bar from "@/components/title_bar/index.vue";
import { useIndexStore } from "@/store/model/index";
import { Events } from "@/utils/events_bus/index.js";

const store = useIndexStore();

const flag = ref(false);


onBeforeMount(async () => {
  const config = await Events.send_reply("get_config","src/config/config.json");
  const pwd = await Events.send_reply("get_config","src/config/pwd.json");
  if(config && pwd){
    store.set_config(config);
    store.set_pwd(pwd);
    flag.value = true;
  }else{
    alert("配置文件读取失败，请检查配置文件是否存在"); 
  }
  
})

</script>
